package com.itlong.cloud.operate.service.impl;

import com.itlong.cloud.POJO.DTO.operate.ParkingRecordPageDTO;
import com.itlong.cloud.POJO.VO.operate.OperateFixedCarFeeRecordVO;
import com.itlong.cloud.POJO.VO.operate.OperateTemporaryCarFeeRecordVO;
import com.itlong.cloud.operate.dao.IOperateParkingFeeRecordDao;
import com.itlong.cloud.operate.service.IOperateParkingFeeRecordService;
import com.itlong.cloud.utils.data.handler.SqlUtil;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-智慧停车-停车缴费记录接口实现类.
 * </desc>
 *
 * @createDate 2018/11/5
 */
@Service
public class OperateParkingFeeRecordServiceImpl implements IOperateParkingFeeRecordService {

    @Autowired
    IOperateParkingFeeRecordDao ioperateParkingFeeRecordDao;

    /**
     * <desc>
     *      固定车缴费记录分页查询
     * <desc/>
     *
     * @param feeRecordDTO 分页查询参数
     * @return 分页列表数据
     * @author Juguang.S
     * @createDate 2018/11/5
     */
    @Override
    public Page<OperateFixedCarFeeRecordVO> getFixedCarFeeRecordPage(ParkingRecordPageDTO feeRecordDTO) throws Exception{

        //将DTO转换为Map
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(feeRecordDTO);
        //分页默认pageSize为20
        Page<OperateFixedCarFeeRecordVO> page = new Page<>();
        page.getPage().setPageSize(feeRecordDTO.getPageSize());
        page.getPage().setCurrentPage(feeRecordDTO.getCurrentPage());
        params.put("currentPage",page.getPage().getStartSlip());
        params.put("pageSize",page.getPage().getPageSize());
        List<OperateFixedCarFeeRecordVO> list = ioperateParkingFeeRecordDao.getFixedCarFeeRecordPage(params);
        Integer count = ioperateParkingFeeRecordDao.getFixedCarFeeRecordPageCount(params);
        page.setRows(list,count);
        return page;
    }

    /**
     * <desc>
     *      临时车缴费记录分页查询
     * <desc/>
     *
     * @param feeRecordDTO 分页查询参数
     * @return 标准返回结果
     * @author Juguang.S
     * @createDate 2018/11/5
     */
    @Override
    public Page<OperateTemporaryCarFeeRecordVO> getTemporaryCarFeeRecordPage(ParkingRecordPageDTO feeRecordDTO) throws Exception {
        //将DTO转换为Map
        Map<String,Object> params = SqlUtil.convertBeanToMapParams(feeRecordDTO);
        //分页默认pageSize为20
        Page<OperateTemporaryCarFeeRecordVO> page = new Page<>();
        page.getPage().setPageSize(feeRecordDTO.getPageSize());
        page.getPage().setCurrentPage(feeRecordDTO.getCurrentPage());
        params.put("currentPage",page.getPage().getStartSlip());
        params.put("pageSize",page.getPage().getPageSize());
        List<OperateTemporaryCarFeeRecordVO> list = ioperateParkingFeeRecordDao.getTemporaryCarFeeRecordPage(params);
        Integer count = ioperateParkingFeeRecordDao.getTemporaryCarFeeRecordCount(params);
        page.setRows(list,count);
        return page;
    }
}